﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using GRWL.BZSC.DataLinq;
using System.Collections;
using System.Data;

namespace GRWL.BZSC.WCFLib
{
    // 注意: 如果更改此处的接口名称 "IBaseData"，也必须更新 App.config 中对 "IBaseData" 的引用。
    /// <summary>
    /// 包装生产业务数据访问接口
    /// </summary>
    [ServiceContract]
    public interface IBaseData
    {
        #region 基础数据部分

        #region 通用选项管理

        /// <summary>
        /// 获取单个选项信息
        /// </summary>
        /// <param name="id">选项系统编号</param>
        /// <returns>选项对象</returns>
        [OperationContract]
        TB_Options GetOption(int id);


        /// <summary>
        /// 获取单个选项信息
        /// </summary>
        /// <param name="type">选项类型</param>
        /// <param name="name">选项名称</param>
        /// <returns>选项对象</returns>
        [OperationContract]
        TB_Options GetOptionByTpNm(string type, string name);

        [OperationContract]
        /// <summary>
        /// 获取选项树形关系
        /// </summary>        
        /// <param name="type">选项类型</param>
        /// <returns>TB_Options</returns>               
        IEnumerable<TB_Options> GetOptionTree(string type);

        /// <summary>
        /// 查找选项
        /// </summary>
        /// <param name="type">选项类型</param>
        /// <param name="code">选项代号</param>
        /// <param name="name">选项名称</param>
        /// <returns>TB_Options</returns>
        [OperationContract]
        IEnumerable<TB_Options> FindOptions(string type, string code, string name);

        [OperationContract]
        /// <summary>
        /// 新增选项
        /// </summary>
        /// <param name="option">选项</param>
        /// <returns>新建选项系统编号</returns>
        int AddOption(TB_Options option);

        [OperationContract]
        /// <summary>
        /// 更新一个选项
        /// </summary>
        /// <param name="option">选项类</param>
        /// <returns>是否更新成功</returns>
        bool UpdateOption(TB_Options option);

        [OperationContract]
        /// <summary>
        /// 删除一个选项
        /// </summary>
        /// <param name="id">选项系统编号</param>
        /// <returns>是否删除成功</returns>
        bool DeleteOption(int id);
        #endregion

        #region 往来单位管理

        [OperationContract]
        /// <summary>
        /// 获取单个往来单位信息
        /// </summary>
        /// <param name="id">往来单位系统编号</param>
        /// <returns>往来单位对象</returns>
        TB_Trader GetTrader(int id);

        [OperationContract]
        /// <summary>
        /// 获取一类往来单位
        /// </summary>
        /// <param name="type">类型编号</param>
        /// <returns>往来单位序列</returns>
        IEnumerable<TB_Trader> GetTraders(int type);

        /// <summary>
        /// 搜索往来单位
        /// </summary>
        /// <param name="type">类型</param>
        /// <param name="isSupplier">是否供应商</param>
        /// <param name="isClient">是否客户</param>
        /// <param name="name">名称</param>
        /// <param name="linkman">联系人</param>
        /// <returns>往来单位序列</returns>
        [OperationContract]
        IEnumerable<TB_Trader> FindTraders(int? type, bool? isSupplier, bool? isClient, string code, string name, string linkman);

        [OperationContract]
        /// <summary>
        /// 新增往来单位
        /// </summary>
        /// <param name="trader">往来单位</param>
        /// <returns>新建选项系统编号</returns>
        int AddTrader(TB_Trader trader);

        [OperationContract]
        /// <summary>
        /// 更新一个往来单位
        /// </summary>
        /// <param name="trader">往来单位类</param>
        /// <returns>是否更新成功</returns>
        bool UpdateTrader(TB_Trader trader);

        [OperationContract]
        /// <summary>
        /// 删除一个往来单位
        /// </summary>
        /// <param name="id">往来单位系统编号</param>
        /// <returns>是否删除成功</returns>
        bool DeleteTrader(int id);
        #endregion

        #region 物料管理

        /// <summary>
        /// 获取单个物料信息
        /// </summary>
        /// <param name="id">物料系统编号</param>
        /// <returns>物料对象</returns>
        [OperationContract]
        TB_Material GetMaterial(int id);

        /// <summary>
        /// 获取单个物料信息附带关联信息
        /// </summary>
        /// <param name="id">物料系统编号</param>
        /// <param name="id">库存Id</param>
        /// <param name="batchNo">出入仓批次</param>
        /// <returns>XMaterial</returns>
        [OperationContract]
        XMaterial GetXMaterial(int id, int? stockId,string batchNo);

        /// <summary>
        /// 查找物料
        /// </summary>
        /// <param name="type">类型</param>
        /// <param name="depotCategory">仓库类型</param>
        /// <param name="depot">仓库</param>
        /// <param name="code">代码</param>
        /// <param name="name">名称</param>
        /// <param name="specs">规格</param>
        /// <param name="source">来源</param>
        /// <param name="isPurchase">是否采购件</param>
        /// <param name="isNominal">是否虚设件</param>
        /// <returns>物料对象序列</returns>
        [OperationContract]
        IEnumerable<QMaterial> FindMaterials(bool? stockNullable, int? type, int? depotCategory, int? depot, string code, string name, string specs, string source, bool? isPurchase, bool? isNominal);

        /// <summary>
        /// 新增物料
        /// </summary>
        /// <param name="option">物料</param>
        /// <returns>新建物料系统编号</returns>
        [OperationContract]
        int AddMaterial(TB_Material material);

        /// <summary>
        /// 更新一个物料
        /// </summary>
        /// <param name="option">物料类</param>
        /// <returns>是否更新成功</returns>
        [OperationContract]
        bool UpdateMaterial(TB_Material material);

        /// <summary>
        /// 删除一个物料
        /// </summary>
        /// <param name="id">物料系统编号</param>
        /// <returns>是否删除成功</returns>
        [OperationContract]
        bool DeleteMaterial(int id);

        /// <summary>
        /// 存储过程检查物料删除
        /// </summary>
        /// <param name="id">物料Id</param>
        /// <returns>SPResult</returns>
        [OperationContract]
        SPResult SPDeleteMaterial(int id);
        #endregion

        #region 仓库管理

        [OperationContract]
        /// <summary>
        /// 获取单个仓库
        /// </summary>
        /// <param name="id">仓库系统编号</param>
        /// <returns>仓库对象</returns>
        TB_Depot GetDepot(int id);

        /// <summary>
        /// 查找仓库
        /// </summary>
        /// <param name="code">代号</param>
        /// <param name="name">名称</param>
        /// <param name="type">分类</param>
        /// <returns>仓库对象序列</returns>
        [OperationContract]
        IEnumerable<TB_Depot> FindDepots(string code, string name, int? type);

        [OperationContract]
        /// <summary>
        /// 新增仓库
        /// </summary>
        /// <param name="depot">仓库</param>
        /// <returns>新建仓库系统编号</returns>
        int AddDepot(TB_Depot depot);

        [OperationContract]
        /// <summary>
        /// 更新一个仓库
        /// </summary>
        /// <param name="option">仓库类</param>
        /// <returns>是否更新成功</returns>
        bool UpdateDepot(TB_Depot depot);

        [OperationContract]
        /// <summary>
        /// 删除一个仓库
        /// </summary>
        /// <param name="id">仓库系统编号</param>
        /// <returns>是否删除成功</returns>
        bool DeleteDepot(int id);
        #endregion

        #region 质检结果管理

        /// <summary>
        /// 获取单个质检结果
        /// </summary>
        /// <param name="id">质检结果系统编号</param>
        /// <returns>质检结果对象</returns>
        [OperationContract]
        TB_QCResult GetQCResult(int id);

        /// <summary>
        /// 查找质检结果
        /// </summary>
        /// <returns>仓库对象序列</returns>
        [OperationContract]
        IEnumerable<TB_QCResult> FindQCResults();

        /// <summary>
        /// 新增质检结果
        /// </summary>
        /// <param name="obj">质检结果</param>
        /// <returns>新建质检结果系统编号</returns>
        [OperationContract]
        int AddQCResult(TB_QCResult obj);

        /// <summary>
        /// 更新一个质检结果
        /// </summary>
        /// <param name="obj">质检结果类</param>
        /// <returns>是否更新成功</returns>
        [OperationContract]
        bool UpdateQCResult(TB_QCResult obj);


        /// <summary>
        /// 删除一个质检结果
        /// </summary>
        /// <param name="id">质检结果系统编号</param>
        /// <returns>是否删除成功</returns>
        [OperationContract]
        bool DeleteQCResult(int id);
        #endregion

        #region 质检问题类型管理

        /// <summary>
        /// 获取单个质检问题类型
        /// </summary>
        /// <param name="id">质检问题类型系统编号</param>
        /// <returns>质检问题类型对象</returns>
        [OperationContract]
        TB_QCProblemType GetQCProblemType(int id);

        /// <summary>
        /// 查找质检问题类型
        /// </summary>
        /// <returns>质检问题类型序列</returns>
        [OperationContract]
        IEnumerable<TB_QCProblemType> FindQCProblemTypes();

        /// <summary>
        /// 新增质检问题类型
        /// </summary>
        /// <param name="obj">质检问题类型</param>
        /// <returns>新建质检问题类型系统编号</returns>
        [OperationContract]
        int AddQCProblemType(TB_QCProblemType obj);

        /// <summary>
        /// 更新一个质检问题类型
        /// </summary>
        /// <param name="obj">质检问题类型类</param>
        /// <returns>是否更新成功</returns>
        [OperationContract]
        bool UpdateQCProblemType(TB_QCProblemType obj);


        /// <summary>
        /// 删除一个质检问题类型
        /// </summary>
        /// <param name="id">质检问题类型系统编号</param>
        /// <returns>是否删除成功</returns>
        [OperationContract]
        bool DeleteQCProblemType(int id);
        #endregion

        #region 工序管理
        /// <summary>
        /// 获取单个工序信息
        /// </summary>
        /// <param name="id">工序系统编号</param>
        /// <returns>工序类型</returns>
        [OperationContract]
        TB_Workstage GetWorkstage(int id);

        /// <summary>
        /// 获取工序关系树
        /// </summary>
        /// <returns></returns>
        [OperationContract]
        IEnumerable<WorkstageTreeNode> GetWorkstageTree();

        /// <summary>
        /// 搜索工序
        /// </summary>
        /// <param name="parentId">上级工序</param>
        /// <returns>工序序列</returns>
        [OperationContract]
        IEnumerable<TB_Workstage> FindWorkstage(int? parentId);

        /// <summary>
        /// 新增工序
        /// </summary>
        /// <param name="obj">工序类型</param>
        /// <returns>新增工序系统编号</returns>
        [OperationContract]
        int AddWorkstage(TB_Workstage obj);

        /// <summary>
        /// 更新工序
        /// </summary>
        /// <param name="obj">工序类型</param>
        /// <returns>更新是否成功</returns>
        [OperationContract]
        bool UpdateWorkstage(TB_Workstage obj);

        /// <summary>
        /// 删除工序
        /// </summary>
        /// <param name="id">工序系统编号</param>
        /// <returns>删除是否成功</returns>
        [OperationContract]
        bool DeleteWorkstage(int id);
        #endregion

        #region 部门管理
        /// <summary>
        /// 获取单个部门信息
        /// </summary>
        /// <param name="id">部门系统编号</param>
        /// <returns>部门类型</returns>
        [OperationContract]
        TB_Department GetDepartment(int id);

        /// <summary>
        /// 搜索部门
        /// </summary>
        /// <param name="parentId">上级部门</param>
        /// <param name="code">部门代号</param>
        /// <param name="name">部门名称</param>
        /// <returns>部门序列</returns>
        [OperationContract]
        IEnumerable<TB_Department> FindDepartments(int? parentId,string code,string name);

        /// <summary>
        /// 新增部门
        /// </summary>
        /// <param name="obj">部门类型</param>
        /// <returns>新增部门系统编号</returns>
        [OperationContract]
        int AddDepartment(TB_Department obj);

        /// <summary>
        /// 更新部门
        /// </summary>
        /// <param name="obj">部门类型</param>
        /// <returns>更新是否成功</returns>
        [OperationContract]
        bool UpdateDepartment(TB_Department obj);

        /// <summary>
        /// 删除部门
        /// </summary>
        /// <param name="id">部门系统编号</param>
        /// <returns>删除是否成功</returns>
        [OperationContract]
        bool DeleteDepartment(int id);
        #endregion

        #region 用户管理
        /// <summary>
        /// 获取单个用户信息
        /// </summary>
        /// <param name="id">用户系统编号</param>
        /// <returns>用户类型</returns>
        [OperationContract]
        TB_User GetUser(int id);

        /// <summary>
        /// 根据用户代号获取带关联的用户
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        [OperationContract]
        XUser GetLoginUser(string code);

        /// <summary>
        /// 搜索用户
        /// </summary>
        /// <param name="parentId">上级部门</param>
        /// <returns>部门序列</returns>
        [OperationContract]
        IEnumerable<XUser> FindUsers(int? department, string code, string name);

        /// <summary>
        /// 新增用户
        /// </summary>
        /// <param name="obj">用户类型</param>
        /// <returns>新增用户系统编号</returns>
        [OperationContract]
        int AddUser(TB_User obj);

        /// <summary>
        /// 更新用户
        /// </summary>
        /// <param name="obj">用户类型</param>
        /// <returns>更新是否成功</returns>
        [OperationContract]
        bool UpdateUser(TB_User obj);

        /// <summary>
        /// 删除用户
        /// </summary>
        /// <param name="id">用户系统编号</param>
        /// <returns>删除是否成功</returns>
        [OperationContract]
        bool DeleteUser(int id);

        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="code"></param>
        /// <param name="pwd"></param>
        /// <returns>错误消息</returns>
        [OperationContract]
        LoginResult CheckLogin(string code, string pwd);
        #endregion

        #region 获取流水号
        /// <summary>
        /// 获取流水号（单据、分类）
        /// </summary>
        /// <param name="type">1-单据,2-分类</param>
        /// <param name="billType">单据类型</param>
        /// <param name="len">自定义流水号长度</param>
        /// <param name="prefix">是否加前缀</param>
        /// <param name="fillZero">是否补零</param>
        /// <returns>流水号</returns>
        [OperationContract]
        string GetSerialNo(int type, string billType, int len, bool prefix, bool fillZero, bool fillDate);
        #endregion

        #endregion

        #region 进销存部分

        #region 收发货管理
        /// <summary>
        /// 获取单个收发货单数据
        /// </summary>
        /// <param name="id">系统编码</param>
        /// <returns>TB_Shipping</returns>
        [OperationContract]
        TB_Shipping GetShipping(int id);

        /// <summary>
        /// 获取单个收发货单数据
        /// </summary>
        /// <param name="id">系统编码</param>
        /// <returns>XShipping</returns>
        [OperationContract]
        XShipping GetXShipping(int id);

        /// <summary>
        /// 搜索收发货单
        /// </summary>
        /// <param name="type">单据类型</param>
        /// <param name="code">单据代号</param>
        /// <param name="operatorName">制单人名称</param>
        /// <param name="status">单据状态</param>
        /// <param name="sDate">制单开始时间</param>
        /// <param name="eDate">制单结束时间</param>
        /// <param name="trader">往来单位</param>
        /// <param name="materailCode">物料代号</param>
        /// <param name="materialCategory">物料分类</param>
        /// <param name="materialName">物料名称</param>
        /// <returns></returns>
        [OperationContract]
        IEnumerable<QShipping> FindShippings(string type, string code, string operatorName, string status, DateTime? sDate, DateTime? eDate, int? trader, string materailCode, int? materialCategory, string materialName);

        /// <summary>
        /// 新增收发货单
        /// </summary>
        /// <param name="obj">收发货单</param>
        /// <returns>新增收发货单系统编号</returns>
        [OperationContract]
        int AddShipping(TB_Shipping obj);

        /// <summary>
        /// 更新收发货单
        /// </summary>
        /// <param name="obj">收发货单</param>
        /// <returns>更新是否成功</returns>
        [OperationContract]
        bool UpdateShipping(TB_Shipping shipping, bool updateSubs);

        /// <summary>
        /// 删除收发货单
        /// </summary>
        /// <param name="id">收发货单系统编号</param>
        /// <returns>删除是否成功</returns>
        [OperationContract]
        bool DeleteShipping(int id);
        #endregion

        #region 收发货明细管理
        /// <summary>
        /// 获取单个收发货明细数据
        /// </summary>
        /// <param name="id">收发货明细系统编码</param>
        /// <returns>TB_ShippingDetail</returns>
        [OperationContract]
        TB_ShippingDetail GetShippingDetail(int id);

        /// <summary>
        /// 获取单个收发货明细数据
        /// </summary>
        /// <param name="id">收发货明细系统编码</param>
        /// <returns>XShippingDetail</returns>
        [OperationContract]
        XShippingDetial GetXShippingDetail(int id);

        /// <summary>
        /// 根据收发货单获取收发货明细
        /// </summary>
        /// <param name="id">收发货单系统编码</param>
        /// <returns>TB_ShippingDetail序列</returns>
        [OperationContract]
        IEnumerable<XShippingDetial> GetShippingDetails(int id);

        /// <summary>
        /// 新增收发货明细
        /// </summary>
        /// <param name="obj">TB_ShippingDetail</param>
        /// <returns>新增收发货明细系统编号</returns>
        [OperationContract]
        int AddShippingDetail(TB_ShippingDetail obj);
        #endregion

        #region 请购
        /// <summary>
        /// 获取单个请购单数据
        /// </summary>
        /// <param name="id">系统编码</param>
        /// <returns>TB_Requisition</returns>
        [OperationContract]
        TB_Requisition GetRequisition(int id);

        /// <summary>
        /// 获取单个带关联的请购单
        /// </summary>
        /// <param name="id">系统编码</param>
        /// <returns>XRequisition</returns>
        [OperationContract]
        XRequisition GetXRequisition(int id);

        /// <summary>
        /// 搜查带关联的请购单
        /// </summary>
        /// <param name="code">请购单号</param>
        /// <param name="operatorName">制单人名称</param>
        /// <param name="status">请购单状态</param>
        /// <param name="sDate">开始时间</param>
        /// <param name="eDate">结束时间</param>
        /// <param name="materailCode">物料代号</param>
        /// <param name="materialCategory">物料分类名</param>
        /// <param name="materialName">物料名称</param>
        /// <returns></returns>
        [OperationContract]
        IEnumerable<QRequisition> FindRequisitions(string code, string operatorName, string status, DateTime? sDate, DateTime? eDate, string materailCode, int? materialCategory, string materialName);

        /// <summary>
        /// 新增请购单
        /// </summary>
        /// <param name="obj">请购单</param>
        /// <returns>新增请购单系统编号</returns>
        [OperationContract]
        int AddRequisition(TB_Requisition obj);

        /// <summary>
        /// 更新请购单
        /// </summary>
        /// <param name="requisition">请购单类型</param>
        /// <param name="requisitionDetails">请购明细</param>
        /// <returns>更新是否成功</returns>
        [OperationContract]
        bool UpdateRequisition(TB_Requisition requisition, bool updateSubs);

        /// <summary>
        /// 删除请购单
        /// </summary>
        /// <param name="id">请购单系统编号</param>
        /// <returns>删除是否成功</returns>
        [OperationContract]
        bool DeleteRequisition(int id);
        #endregion

        #region 请购明细
        /// <summary>
        /// 获取单个请购明细数据
        /// </summary>
        /// <param name="id">请购明细系统编码</param>
        /// <returns>TB_ReqDetail</returns>
        [OperationContract]
        TB_ReqDetail GetReqDetail(int id);

        /// <summary>
        /// 获取单个带关联的请购明细
        /// </summary>
        /// <param name="id">请购明细系统编码</param>
        /// <returns>XReqDetial</returns>
        [OperationContract]
        XReqDetial GetXReqDetail(int id);

        /// <summary>
        /// 根据请购单获取请购明细
        /// </summary>
        /// <param name="id">请购单系统编码</param>
        /// <returns>TB_ReqDetail序列</returns>
        [OperationContract]
        IEnumerable<TB_ReqDetail> GetReqDetails(int id);

        /// <summary>
        /// 根据请购单获取带关联的请购明细
        /// </summary>
        /// <param name="id">请购单系统编码</param>
        /// <returns>XReqDetail序列</returns>
        [OperationContract]
        IEnumerable<XReqDetial> GetXReqDetails(int id);

        /// <summary>
        /// 新增请购明细
        /// </summary>
        /// <param name="obj">TB_ReqDetail</param>
        /// <returns>新增请购明细系统编号</returns>
        [OperationContract]
        int AddReqDetail(TB_ReqDetail obj);
        #endregion

        #region 质检单
        /// <summary>
        /// 获取一个带关联的质检单
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [OperationContract]
        XQC GetXQC(int id);

        /// <summary>
        /// 搜索质检单
        /// </summary>
        /// <param name="type"></param>
        /// <param name="code"></param>
        /// <param name="operatorName"></param>
        /// <param name="status"></param>
        /// <param name="sDate"></param>
        /// <param name="eDate"></param>
        /// <returns></returns>
        [OperationContract]
        IEnumerable<QQC> FindQCs(string type, string code, string operatorName, string status, DateTime? sDate, DateTime? eDate);

        /// <summary>
        /// 新增质检单
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        [OperationContract]
        int AddQC(TB_QC obj);

        /// <summary>
        /// 更新质检单
        /// </summary>
        /// <param name="?"></param>
        /// <param name="qcDetails"></param>
        /// <param name="qcProblems"></param>
        /// <returns></returns>
        [OperationContract]
        bool UpdateQC(TB_QC obj);

        /// <summary>
        /// 删除质检单
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [OperationContract]
        bool DeleteQC(int id);
        #endregion

        #region 质检单明细
        /// <summary>
        /// 获取单个带关联的质检明细
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [OperationContract]
        XQCDetail GetXQCDetail(int id);

        /// <summary>
        /// 根据质检单id获取带关联的质检明细
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [OperationContract]
        IEnumerable<XQCDetail> GetXQCDetials(int id);

        ///// <summary>
        ///// 新增质检明细
        ///// </summary>
        ///// <param name="obj"></param>
        ///// <param name="qcProblems"></param>
        ///// <returns></returns>
        //[OperationContract]
        //int AddQCDetial(TB_QCDetail obj, IEnumerable<TB_QCProblem> qcProblems);
        #endregion

        #region 质检问题明细
        /// <summary>
        /// 获取单个带关联的质检问题明细
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [OperationContract]
        XQCProblem GetXQCProblem(int id);

        /// <summary>
        /// 根据质检单明细id获取带关联的质检问题明细
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [OperationContract]
        IEnumerable<XQCProblem> GetXQCProblems(int id);

        ///// <summary>
        ///// 新增质检问题明细
        ///// </summary>
        ///// <param name="obj"></param>
        ///// <returns></returns>
        //[OperationContract]
        //int AddQCProblem(TB_QCProblem obj);
        #endregion

        #region 报价单
        /// <summary>
        /// 获取一个带关联的报价单
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [OperationContract]
        XQuotation GetXQuotation(int id);

        /// <summary>
        /// 搜查带关联的报价单
        /// </summary>
        /// <param name="code">报价单号</param>
        /// <param name="operatorName">制单人名称</param>
        /// <param name="status">请购单状态</param>
        /// <param name="sDate">开始时间</param>
        /// <param name="eDate">结束时间</param>
        /// <param name="materailCode">物料代号</param>
        /// <param name="materialCategory">物料分类名</param>
        /// <param name="materialName">物料名称</param>
        /// <returns></returns>
        [OperationContract]
        IEnumerable<QQuotation> FindQuotations(string code, string operatorName, string status, DateTime? sDate, DateTime? eDate, string materailCode, int? materialCategory, string materialName);

        /// <summary>
        /// 新增报价单
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        [OperationContract]
        int AddQuotation(TB_Quotation obj);

        /// <summary>
        /// 更新报价单
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="details"></param>
        /// <returns></returns>
        [OperationContract]
        bool UpdateQuotation(TB_Quotation obj, bool updateSubs);

        /// <summary>
        /// 删除报价单
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [OperationContract]
        bool DeleteQuotation(int id);
        #endregion

        #region 报价单明细
        /// <summary>
        /// 获取单个带关联的报价明细
        /// </summary>
        /// <param name="id">报价明细系统编码</param>
        /// <returns>XQuoteDetial</returns>
        [OperationContract]
        XQuoteDetial GetXQuoteDetial(int id);

        /// <summary>
        /// 根据报价单获取带关联的报价明细
        /// </summary>
        /// <param name="id">报价单系统编码</param>
        /// <returns>XQuoteDetial序列</returns>
        [OperationContract]
        IEnumerable<XQuoteDetial> GetXQuoteDetials(int id);

        /// <summary>
        /// 新增报价明细
        /// </summary>
        /// <param name="obj">TB_ReqDetail</param>
        /// <returns>新增报价明细系统编号</returns>
        [OperationContract]
        int AddQuoteDetail(TB_QuoteDetail obj);
        #endregion

        #region 订单
        /// <summary>
        /// 获取一个带关联的订单
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [OperationContract]
        XOrder GetXOrder(int id);

        /// <summary>
        /// 搜查带关联的订单
        /// </summary>
        /// <param name="orderType">订单类型</param>
        /// <param name="code">订单号</param>
        /// <param name="operatorName">制单人名称</param>
        /// <param name="status">状态</param>
        /// <param name="sDate">开始时间</param>
        /// <param name="eDate">结束时间</param>
        /// <param name="materailCode">物料代号</param>
        /// <param name="materialCategory">物料分类名</param>
        /// <param name="materialName">物料名称</param>
        /// <param name="isMRP">是否已运行MRP需求</param>
        /// <param name="isCheck">是否经过质检</param>
        /// <returns></returns>
        [OperationContract]
        IEnumerable<QOrder> FindOrders(string orderType, string code, string operatorName, string status, DateTime? sDate, DateTime? eDate, string materailCode, int? materialCategory, string materialName, bool? isMRP, bool? isProduce, bool? isCheck);


        /// <summary>
        /// 新增订单
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        [OperationContract]
        int AddOrder(TB_Order obj);

        /// <summary>
        /// 更新订单
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="details"></param>
        /// <returns></returns>
        [OperationContract]
        bool UpdateOrder(TB_Order obj, bool updateSubs);

        /// <summary>
        /// 删除订单
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [OperationContract]
        bool DeleteOrder(int id);
        #endregion

        #region 订单明细
        /// <summary>
        /// 获取单个带关联的订单明细
        /// </summary>
        /// <param name="id">订单明细系统编码</param>
        /// <returns>XOrderDetail</returns>
        [OperationContract]
        XOrderDetail GetXOrderDetail(int id);

        /// <summary>
        /// 根据订单获取带关联的订单明细
        /// </summary>
        /// <param name="id">订单系统编码</param>
        /// <returns>XOrderDetail序列</returns>
        [OperationContract]
        IEnumerable<XOrderDetail> GetXOrderDetails(int id);

        /// <summary>
        /// 新增报价明细
        /// </summary>
        /// <param name="obj">TB_ReqDetail</param>
        /// <returns>新增报价明细系统编号</returns>
        [OperationContract]
        int AddOrderDetail(TB_OrderDetail obj);
        #endregion

        #region 库存管理
        /// <summary>
        /// 查找带关联的物料库存批次情况
        /// </summary>
        /// <param name="id"></param>
        [OperationContract]
        IEnumerable<XStock> GetBatchStocks(int id);

        /// <summary>
        /// 获取材料当前库存
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [OperationContract]
        decimal? GetCurrentStock(int id);

        /// <summary>
        /// 库存单据查询存储过程
        /// </summary>
        /// <param name="sDate"></param>
        /// <param name="eDate"></param>
        /// <param name="category"></param>
        /// <param name="material"></param>
        /// <param name="depotCategory"></param>
        /// <param name="depot"></param>
        /// <returns></returns>
        [OperationContract]
        QStockBill[] QueryStockIO(DateTime? sDate, DateTime? eDate, int? category, int? material, int? depotCategory, int? depot);

        /// <summary>
        /// 库存金额查询
        /// </summary>
        /// <param name="materialCategory">物资分类</param>
        /// <param name="depotCategory">仓库分类</param>
        /// <param name="depot">仓库id</param>
        /// <returns></returns>
        [OperationContract]
        QStockAmount[] QueryStockAmount(int? materialCategory, int? depotCategory, int? depot);
        #endregion

        #region 单据审批
        /// <summary>
        /// 单据审批
        /// </summary>
        /// <param name="billType"></param>
        /// <param name="billId"></param>
        /// <param name="operatorId"></param>
        /// <param name="verify"></param>
        /// <returns></returns>
        [OperationContract]
        VerifyBillResult VerifyBill(string billType, int billId, int operatorId, bool verify);
        #endregion
        #endregion

        #region 生产管理部分

        #region 领料单
        /// <summary>
        /// 获取单个领料单
        /// </summary>
        /// <param name="id">领料单id</param>
        /// <returns>TB_RecvMaterial</returns>
        [OperationContract]
        TB_RecvMaterial GetRecvMaterial(int id);

        /// <summary>
        /// 带关联的领料单
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [OperationContract]
        XRecvMaterial GetXRecvMaterial(int id);

        [OperationContract]
        IEnumerable<QRecvMaterial> FindRecvMaterials(string code, string operatorName, string status, DateTime? sDate, DateTime? eDate, string materailCode, int? materialCategory, string materialName);

        /// <summary>
        /// 更新领料单
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="details"></param>
        /// <returns></returns>
        [OperationContract]
        bool UpdateRecvMaterial(TB_RecvMaterial obj, bool updateSubs);

        /// <summary>
        /// 新增领料单
        /// </summary>
        /// <param name="obj">领料单</param>
        /// <returns>新增领料单系统编号</returns>
        [OperationContract]
        int AddRecvMaterial(TB_RecvMaterial obj);

        /// <summary>
        /// 删除领料单
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [OperationContract]
        bool DeleteRecvMaterial(int id);

        #endregion

        #region 领料明细
        /// <summary>
        /// 获取单个领料明细
        /// </summary>
        /// <param name="id">领料明细Id</param>
        /// <returns>TB_RecvDetail</returns>
        [OperationContract]
        TB_RecvDetail GetRecvDetail(int id);

        /// <summary>
        /// 获取带关联的单个领料明细
        /// </summary>
        /// <param name="id">领料明细id</param>
        /// <returns>XRecvDetail</returns>
        [OperationContract]
        XRecvDetail GetXRecvDetail(int id);

        /// <summary>
        /// 根据领料单Id获取领料明细
        /// </summary>
        /// <param name="id">领料单Id</param>
        /// <returns>IEnumerable<XRecvDetail></returns>
        [OperationContract]
        IEnumerable<XRecvDetail> GetRecvDetails(int id);

        /// <summary>
        /// 新增领料明细
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        [OperationContract]
        int AddRecvDetail(TB_RecvDetail obj);
        #endregion

        #endregion

        #region MRP部分

        #region 工程审批
        /// <summary>
        /// 工程审批
        /// </summary>
        /// <param name="prjtId"></param>
        /// <param name="prjtCode"></param>
        /// <param name="pass"></param>
        /// <param name="verifyStatus"></param>
        /// <returns></returns>
        [OperationContract]
        bool VerifyPrdtPrjt(int prjtId, string prjtCode, bool pass, short verifyStatus);
        #endregion

        #region 产品工程
        /// <summary>
        /// 获取一个产品工程资料
        /// </summary>
        /// <param name="id">产品工程系统编码</param>
        /// <returns></returns>
        [OperationContract]
        TB_ProductProject GetPrdtPrjt(int id);


        // <summary>
        /// 根据元件Id获取相关工程
        /// </summary>
        /// <param name="id">元件Id</param>
        /// <returns></returns>
        [OperationContract]
        IEnumerable<XPrdtPrjt> GetXPrdtPrjts(int id);

        /// <summary>
        /// 获取带关联的产品工程
        /// </summary>
        /// <param name="id">工程Id</param>
        /// <returns>XPrdtPrjt</returns>
        [OperationContract]
        XPrdtPrjt GetXPrdtPrjt(int id);

        /// <summary>
        /// 根据工程元件ID获取下级工程
        /// </summary>
        /// <param name="id">工程元件ID</param>
        /// <returns>TB_ProductProject</returns>
        [OperationContract]
        TB_ProductProject GetSubPrdtPrjt(int id);



        ///// <summary>
        ///// 返回产品工程树节点序列
        ///// </summary>
        ///// <returns></returns>
        //[OperationContract]
        //IEnumerable<PrdtPrjtNode> GetPrdtPrjtNodes();

        /// <summary>
        /// 返回所有带关联的产品工程
        /// </summary>
        /// <returns></returns>
        [OperationContract]
        IEnumerable<XPrdtPrjt> GetPrdtPrjts();

        /// <summary>
        /// 搜索产品工程
        /// </summary>
        /// <param name="isVerify">工程是否已审批，引用工程的时候工程必须已审批</param>
        /// <param name="category">物料类别</param>
        /// <param name="depotCategory">仓库类别</param>
        /// <param name="depot">仓库</param>
        /// <param name="code">产品工程代号</param>
        /// <param name="version">版本号</param>
        /// <param name="engineerName">工程师名称</param>
        /// <param name="submitStatus">提交状态</param>
        /// <param name="verifyStatus">审批状态</param>
        /// <param name="materialCode">物料代号</param>
        /// <param name="materialName">物料名称</param>
        /// <returns>QPrdtPrjt序列</returns>
        [OperationContract]
        IEnumerable<QPrdtPrjt> FindPrdtPrjt(bool? isVerify, int? category, int? depotCategory, int? depot, string code, string version,
            string engineerName, short? submitStatus, short? verifyStatus, string materialCode, string materialName);

        /// <summary>
        /// 新增产品工程
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        [OperationContract]
        int AddPrdtPrjt(TB_ProductProject obj);

        /// <summary>
        /// 更新产品工程
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        [OperationContract]
        bool UpdatePrdtPrjt(TB_ProductProject obj);

        /// <summary>
        /// 删除产品工程
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [OperationContract]
        bool DeletePrdtPrjt(int id);

        /// <summary>
        /// 根据产品工程id或工序Id获取工序序号或元件序号
        /// </summary>
        /// <param name="type">1=工序序号，2-元件序号</param>
        /// <param name="id">产品工程Id或工序Id</param>
        /// <returns>工序序号或元件序号</returns>
        [OperationContract]
        string GetPrdtPrjtSerialNo(int type, int id);

        /// <summary>
        /// 复制产品工程
        /// </summary>
        /// <param name="sPrjt">复制源工程</param>
        /// <param name="dPrjt">目标工程</param>
        /// <returns></returns>
        [OperationContract]
        bool CopyPrdtPrjt(int sPrjt, int dPrjt);
        #endregion

        #region 产品工序
        /// <summary>
        /// 根据产品工序Id获取单个产品工序信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [OperationContract]
        TB_ProjectWorkstage GetPrjtWorkstage(int id);

        /// <summary>
        /// 根据产品工序Id获取单个带关联的产品工序
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [OperationContract]
        XPrjtWorkstage GetXPrjtWorkstage(int id);

        ///// <summary>
        ///// 根据产品工程Id获取产品工程工序树节点类型数据
        ///// </summary>
        ///// <param name="id">产品工程编号</param>
        ///// <returns>PrdtWorkstageNode</returns>
        //[OperationContract]
        //IEnumerable<XPrjtWorkstage> FindPrjtWorkstages(int id);

        ///// <summary>
        ///// 根据物料id获取对应的工程工序树节点
        ///// </summary>
        ///// <param name="id"></param>
        ///// <returns></returns>
        //[OperationContract]
        //PrjtWorkstageNode GetPrjtWorkstageNode(int id);

        /// <summary>
        /// 根据产品工程Id获取产品工程工序数据
        /// </summary>
        /// <param name="id">产品工程Id</param>
        /// <returns>XPrjtWorkstage</returns>
        [OperationContract]
        IEnumerable<XPrjtWorkstage> FindPrjtWorkstages(int id);

        /// <summary>
        /// 新增产品工序
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        [OperationContract]
        int AddPrjtWorkstage(TB_ProjectWorkstage obj);

        /// <summary>
        /// 更新产品工序
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        [OperationContract]
        bool UpdatePrjtWorkstage(TB_ProjectWorkstage obj);

        /// <summary>
        /// 删除产品工序
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [OperationContract]
        bool DeletePrjtWorkstage(int id);
        #endregion

        #region 元件

        /// <summary>
        /// 获取单个工程元件
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [OperationContract]
        TB_ProjectElement GetPrjtElement(int id);

        /// <summary>
        /// 获取带关联的元件
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [OperationContract]
        XPrjtElement GetXPrjtElement(int id);

        ///// <summary>
        ///// 根据工序id获取所需元件树节点
        ///// </summary>
        ///// <param name="id">工序id</param>
        ///// <returns></returns>
        //[OperationContract]
        //IEnumerable<PrjtElementNode> FindPrjtElementNodes(int id);

        /// <summary>
        /// 根据工序id获取所需元件
        /// </summary>
        /// <param name="id">工序id</param>
        /// <returns></returns>
        [OperationContract]
        IEnumerable<XPrjtElement> FindPrjtElements(int id);

        /// <summary>
        /// 新增元件
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        [OperationContract]
        int AddPrjtElement(TB_ProjectElement obj);

        /// <summary>
        /// 更新元件
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        [OperationContract]
        bool UpdatePrjtElement(TB_ProjectElement obj);

        /// <summary>
        /// 删除元件
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [OperationContract]
        bool DeletePrjtElement(int id);
        #endregion

        #region 需求计划
        /// <summary>
        /// 获取单个需求计划单
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [OperationContract]
        TB_Requirement GetRequirement(int id);

        /// <summary>
        /// 获取带关联的需求计划单
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [OperationContract]
        XRequirement GetXRequirement(int id);

        /// <summary>
        /// 搜索复合类型的需求计划
        /// </summary>
        /// <param name="isRelease"></param>
        /// <returns></returns>
        [OperationContract]
        IEnumerable<XRequirement> GetXRequirements(bool? isRelease, string status);

        /// <summary>
        /// 搜索需求计划单
        /// </summary>
        /// <param name="code"></param>
        /// <param name="operatorName"></param>
        /// <param name="status"></param>
        /// <param name="orderCode"></param>
        /// <param name="sDate"></param>
        /// <param name="eDate"></param>
        /// <param name="isRelease"></param>
        /// <returns></returns>
        [OperationContract]
        IEnumerable<QRequirement> FindRequirements(string code, string operatorName, string status, string orderCode, DateTime? sDate, DateTime? eDate, bool? isRelease);

        /// <summary>
        /// 新增需求计划
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        [OperationContract]
        int AddRequirement(TB_Requirement obj);


        /// <summary>
        /// 更新需求计划
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="updateSubs">子表是否同步更新</param>
        /// <returns></returns>
        [OperationContract]
        bool UpdateRequirement(TB_Requirement obj, bool updateSubs);

        /// <summary>
        /// 删除需求计划
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [OperationContract]
        bool DeleteRequirement(int id);
        #endregion

        #region 需求计划明细
        /// <summary>
        /// 更新需求明细
        /// </summary>
        /// <param name="objs"></param>
        /// <returns></returns>
        [OperationContract]
        bool UpdateRqrtDetail(TB_RqrtDetail[] objs);

        /// <summary>
        /// 获取带关联的需求计划明细
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [OperationContract]
        XRqrtDetail GetXRqrtDetail(int id);

        /// <summary>
        /// 根据需求计划单ID货相关明细
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [OperationContract]
        IEnumerable<XRqrtDetail> GetXRqrtDetails(int[] ids);
        #endregion

        #region 生产单
        /// <summary>
        /// 获取单个生产单
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [OperationContract]
        TB_Production GetProduction(int id);

        /// <summary>
        /// 获取带关联的生产单
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [OperationContract]
        XProduction GetXProduction(int id);

        /// <summary>
        /// 搜索生产单
        /// </summary>
        /// <param name="code"></param>
        /// <param name="operatorName"></param>
        /// <param name="status"></param>
        /// <param name="sDate"></param>
        /// <param name="eDate"></param>
        /// <param name="materailCode"></param>
        /// <param name="materialCategory"></param>
        /// <param name="materialName"></param>
        /// <param name="isCheck">是否经过质检</param>
        /// <returns></returns>
        [OperationContract]
        IEnumerable<QProduction> FindProductions(string code, string operatorName, string status, DateTime? sDate, DateTime? eDate, string materailCode, int? materialCategory, string materialName, bool? isCheck);

        /// <summary>
        /// 新增生产单
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        [OperationContract]
        int AddProduction(TB_Production obj);

        /// <summary>
        /// 更新生产单
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        [OperationContract]
        bool UpdateProduction(TB_Production obj);

        /// <summary>
        /// 删除生产单
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [OperationContract]
        bool DeleteProduction(int id);
        #endregion

        #region 生产单明细
        /// <summary>
        /// 获取单个带关联的生产单明细
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [OperationContract]
        XPrdnDetail GetXPrdnDetail(int id);

        /// <summary>
        /// 根据生产单Id获取相关的明细
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [OperationContract]
        IEnumerable<XPrdnDetail> GetXPrdnDetails(int id);

        /// <summary>
        /// 根据明细获取明细相关的带关联的生产工序
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [OperationContract]
        IEnumerable<XPrdnWorkstage> GetXPrdnWorkstages(int id);

        /// <summary>
        /// 更加生产工序获取相关的带关联的材料
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [OperationContract]
        IEnumerable<XPrdnMaterial> GetXPrdnMaterials(int id);
        #endregion

        #region 需求发放
        /// <summary>
        /// 需求发放
        /// </summary>
        /// <param name="method">1、按毛需求，2-按净需求</param>
        /// <param name="op">操作员</param>
        /// <param name="dept">部门</param>
        /// <param name="issueDate">发放日期</param>
        /// <param name="rqrtId">需求Id</param>
        /// <param name="rqrtDetailIds">需求明细Id,以英文逗号分隔的Id字符窜，如："1,2,3"</param>
        /// <returns></returns>
        [OperationContract]
        bool IssueRequirement(int method, int op, int? dept, DateTime issueDate, int rqrtId, string rqrtDetailIds);
        #endregion
        #endregion
    }
}
